import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

// 解决报错
const originalPush = Router.prototype.push,
  originalReplace = Router.prototype.replace
// push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) {
    return originalPush.call(this, location, onResolve, onReject)
  }
  return originalPush.call(this, location).catch((err) => err)
}
// replace
Router.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject) {
    return originalReplace.call(this, location, onResolve, onReject)
  }
  return originalReplace.call(this, location).catch((err) => err)
}
export const routelist = [
  { path: '*', redirect: '/login', hidden: true },
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: '登录',
    component: (resolve) => require(['@/views/Login/index'], resolve),
    meta: {
      isHideHeader: true
    }
  },
  {
    path: '/homeScreen',
    name: '主屏',
    component: (resolve) => require(['@/views/homeScreen/index'], resolve),
    meta: {
      isHideHeader: true
    }
  },
  // {
  //   path: '/secondaryScreen1',
  //   name: '副屏1',
  //   component: (resolve) =>
  //     require(['@/views/secondaryScreen1/index'], resolve),
  //   meta: {
  //     isHideHeader: true
  //   }
  // },
  {
    path: '/secondaryScreen2',
    name: '副屏2',
    component: (resolve) =>
      require(['@/views/secondaryScreen2/index'], resolve),
    meta: {
      isHideHeader: true
    }
  },
  {
    path: '/secondaryScreen1',
    name: '副屏3',
    component: (resolve) =>
      require(['@/views/secondaryScreen3/index'], resolve),
    meta: {
      isHideHeader: true
    }
  }
]
export default new Router({
  // mode: 'history',
  //  : () => ({ y: 0 }),
  routes: routelist
})
